package com.tyson.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tyson.member.entity.BlAdmin;
import com.tyson.member.entity.vo.LoginParamVo;
import com.tyson.member.mapper.BlAdminMapper;
import com.tyson.member.service.BlAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 管理员表 服务实现类
 * </p>
 *
 * @author 沈统顺
 * @since 2021-02-16
 */
@Service
public class BlAdminServiceImpl extends ServiceImpl<BlAdminMapper, BlAdmin> implements BlAdminService {


    /**
     * 登录方法
     *
     * @param vo
     * @return
     */
    @Override
    public String login(LoginParamVo vo) {
//        QueryWrapper<BlAdmin> wrapper = new QueryWrapper<>();
//        wrapper.eq("username",vo.getUsername());
//        BlAdmin user = this.getOne(wrapper);
        BlAdmin user = this.getOne(new QueryWrapper<BlAdmin>().eq("username", vo.getUsername()));
        if (user != null) {
            return user.getUsername();
        } else {
            return null;
        }

    }

    @Override
    public BlAdmin getInfo(String token) {
        BlAdmin user = this.getOne(new QueryWrapper<BlAdmin>().eq("username", token));
        if (user != null) {
            return user;
        } else {
            return null;
        }
    }
}
